package com.springlearn.springsourcecode.chap8;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author wtcode
 * @Description
 * @date 2025/3/31 - 14:26
 */
@RestController
public class MyController {
    @Lazy
    @Autowired
    private BeanForRequest beanForRequest;
    @Lazy
    @Autowired
    private BeanForSession beanForSession;
    @Lazy
    @Autowired
    private BeanForApplication beanForApplication;

    @GetMapping(value = "/test", produces = "text/html")
    public String test(HttpServletRequest request, HttpSession session){
        ServletContext servletContext = request.getServletContext();
        String sb = "<ul>" +
                        "<li>" + "requestScope" + beanForRequest + "</li>" +
                        "<li>" + "sessionScope" + beanForSession + "</li>" +
                        "<li>" + "applicationScope" + beanForApplication + "</li>" +
                    "</ul>";
        return sb;
    }


}
